package com.xmfh.wemedia.service.impl;

import com.xmfh.wemedia.mapper.DdAddViewsMapper;
import com.xmfh.wemedia.service.IDdAddViewsService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: lanlan
 * @Data: 2022/4/5 19:58
 * @Description: 增加浏览量
 */
@Service
public class DdAddViewsServiceImpl implements IDdAddViewsService {
    @Autowired
    DdAddViewsMapper addViewsMapper;

    /**
     * 判断要增加浏览量的类型
     * @param type
     * @param id
     */
    @Override
    public int addViews(String type, int id) {
        switch (type) {
            case "article":
                type = "dd_article";
                break;
            case "album":
                type = "dd_album";
                break;
            case "micro":
                type = "dd_micro";
                break;
            case "question":
                type = "dd_question";
                break;
        }
        return addViewsMapper.addViews(type, id);
    }
}
